<html>
<head>
<script type="text/javascript">
function whichElement(e)
{
var targ;
if (!e)
  {
  var e=window.event;
  }
if (e.target)
  {
  targ=e.target;
  }
else if (e.srcElement)
  {
  targ=e.srcElement;
  }
if (targ.nodeType==3) // defeat Safari bug
  {
  targ = targ.parentNode;
  }
var tname;
tname=targ.tagName;
alert("You clicked on a " + tname + " element.");
}


function whichButton(event)
{

alert(event.keyCode);


}


</script>
</head>

<body onmousedown="whichElement(event)" onkeyup="whichButton(event)">
<p>Click somewhere in the document. An alert box will alert the tag name of the element you clicked on.</p>

<h3>This is a header</h3>
<p>This is a paragraph</p>
<img border="0" src="ball16.gif" width="29" height="28" alt="Ball">
<A HREF="whichKey.html"  name=hlink >ddd</A>

<p><b>Note:</b> Make sure the right frame has focus when trying this example!</p>
<p>Press a key on your keyboard. An alert box will alert the keycode of the key.</p>
</body>

</html>

